def count_red_inner(parents, colors, queries):
    n = len(colors)
    assert len(parents) == len(colors)
    red_counts = [0 for _ in range(n)]

    children = [[] for _ in range(n)]
    for i, p in enumerate(parents):
        if p is not None:
            children[p].append(i)

    def node_count_red(x):
        count = int(colors[x] == 'R')
        for child in children[x]:
            count += node_count_red(child)
        red_counts[x] = count
        return count
    node_count_red(0)

    result = [red_counts[x] for x in queries]
    return result


def count_red(parents_, colors_, queries_):
    parents = [None] + [x-1 for x in parents_]
    queries = [x-1 for x in queries_]
    result = count_red_inner(parents, colors_, queries)
    return result


if __name__ == '__main__':
    n = int(input())
    parents_ = [int(x) for x in input().split()]
    assert n - 1 == len(parents_)
    colors_ = input()
    q = int(input())
    queries_ = []
    for i in range(q):
        queries_.append(int(input()))

    result = count_red(parents_, colors_, queries_)
    for x in result:
        print(x)

"""
5
1 2 1 4
WRWRR
3
3
4
5
"""